package com.java.dormitorymanager.mvc.view;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @program: DormitoryManager
 * @description: 添加宿舍界面
 * @author: ShuangChenYue
 * @create: 2021-05-17 15:52
 **/
@WebServlet(value = "/ViewAddDorm")
public class ViewAddDormServlet extends HttpServlet
{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        System.out.println("点击添加宿舍进入该界面");
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html");
        resp.setCharacterEncoding("utf-8");
        PrintWriter out = resp.getWriter();

        out.println("<!DOCTYPE html>");
        out.println("<html lang=\"en\">");
        out.println("<head>");
        out.println("<meta charset=\"UTF-8\">");
        out.println("<title>添加宿舍</title>");
        out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://localhost:8080/DormitoryManager/css/css-dorm/addDorm.css\">");
        out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://localhost:8080/DormitoryManager/css/css-other/upIcon.css\">");
        out.println("</head>");
        out.println("<body>");
        out.println("<div id=\"divTitle\">");
        out.println("<h1 id=\"h01\"> Manage Dorm</h1>");
        out.println("</div>");
        out.println("<div id=\"registerBox\">");
        out.println("<h1>Add Dorm</h1>");
        out.println("<form id=\"registerForm\" action=\"/DormitoryManager/mvc/addDorm.do\" method=\"post\">");
        out.println("<table id=\"registerTable\">");
        out.println("<tr>");
        out.println("<td id=\"tdDornum\" colspan=\"2\"><i id=\"dornumIcon\" class=\"iconfontAD\">&#xe669;</i><input id=\"inputDornum\" type=\"text\" name=\"dornum\" placeholder=\"宿舍编号\"></td>");
        out.println("</tr>");
        out.println("<tr>");
        out.println("<td id=\"tdType\"><i id=\"TypeIcon\" class=\"iconfontAD\">&#xe694;</i>");
        out.println("<select id=\"selectType\" name=\"type\">");
        out.println("<option value =\"#\">宿舍类别</option>");
        out.println("<option value =\"man\">man</option>");
        out.println("<option value =\"woman\">woman</option>");
        out.println("</select>");
        out.println("</td>");
        out.println("</tr>");
        out.println("<tr>");
        out.println("<td id=\"tdSubmit\" colspan=\"2\"><input id=\"inputSubmit\" type=\"submit\" value=\"Add\" title=\"点击添加\"></td>");
        out.println("</tr>");
        out.println("</table>");
        out.println("</form>");
        out.println("</div>");
        out.println("</body>");
        out.println("</html>");
        out.flush();
        out.close();
    }
}
